package hibernate;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import bean.ClasseBean;


public class ClasseRepository extends GenericRepositry<ClasseBean, Integer>{
	
	public ClasseBean GetById(Integer Id){
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		Criteria criteria = s.createCriteria(ClasseBean.class).add(Restrictions.eq("id_classe", Id));
		ClasseBean cla = (ClasseBean) criteria.uniqueResult();
		s.close();
		return cla;
	}
	
	public List<ClasseBean> GetAll(){
		Session s = HelperSessionFactory.GetSessionFactory().openSession();
		Criteria criteria = s.createCriteria(ClasseBean.class);
		List<ClasseBean> lst = (List<ClasseBean>) criteria.list();
		s.close();
		return lst ;
	}

}
